package org.zsl.entity;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class CustomerRefTestor {

    public void  testRef(){
          CustomerRecord customerRecord = new CustomerRecord();
          customerRecord.setContext("沟通记录");


          Customer customer = new Customer();
          customer.setName("M");
          customer.setGender("male");

          customer.setRecord(customerRecord);
    }


    @Test
    public void  testRef2(){

        Customer customer = new Customer();
        customer.setName("M");
        customer.setGender("male");

        customer.getRecord().setContext("test");

        System.out.println(customer.getRecord().getContext());
    }


    @Test
    public void testAutowire(){

        ApplicationContext context = new ClassPathXmlApplicationContext("beans3.xml");

        Customer customer= (Customer) context.getBean("customer1");

        System.out.println(customer.getRecord().getContext());
    }


    @Test
    public  void testDependOn(){
        ApplicationContext context = new ClassPathXmlApplicationContext("beans5.xml");

       Customer customer1= (Customer) context.getBean("custome002");

        Customer customer2= (Customer) context.getBean("custome002");

        System.out.println(customer1==customer2);
        System.out.println(customer1.getRecord()==customer2.getRecord());

    }
}
